package com.d3works.apps.businessproject.web;

import com.d3works.apps.businessproject.service.TimesheetLineBusinessService;
import com.d3works.apps.hr.db.TimesheetLine;
import com.d3works.exception.service.TraceBackService;
import com.d3works.inject.Beans;
import com.d3works.rpc.ActionRequest;
import com.d3works.rpc.ActionResponse;

public class TimesheetLineBusinessController {

  public void setDefaultToInvoice(ActionRequest request, ActionResponse response) {
    try {
      TimesheetLine timesheetLine = request.getContext().asType(TimesheetLine.class);
      timesheetLine =
          Beans.get(TimesheetLineBusinessService.class).getDefaultToInvoice(timesheetLine);
      response.setValue("toInvoice", timesheetLine.getToInvoice());
    } catch (Exception e) {
      TraceBackService.trace(response, e);
    }
  }

  public void setTimesheet(ActionRequest request, ActionResponse response) {
    try {
      TimesheetLine timesheetLine = request.getContext().asType(TimesheetLine.class);
      timesheetLine = Beans.get(TimesheetLineBusinessService.class).setTimesheet(timesheetLine);
      response.setValues(timesheetLine);
    } catch (Exception e) {
      TraceBackService.trace(response, e);
    }
  }
}
